package cn.bmyi.apiautotest.common;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;

/**
 * 读取config.properties配置
 * 
 * @author 毛建杰
 *
 */
public class Config
{
	public static Properties config = getProperties();

	//环境
	public static String environment = config.getProperty("environment");
	// 环境地址
	public static String host = config.getProperty("host");
	// 接口请求超时时间，单位：秒
	public static int timeout = Integer.parseInt(config.getProperty("timeout"));

	/**
	 * 读取config.properties配置
	 * 
	 * @return Properties
	 */
	public static Properties getProperties()
	{
		Properties properties = new Properties();
		InputStream inputStream = Config.class.getResourceAsStream("/config.properties");
		BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
		try
		{
			properties.load(bufferedReader);
		}
		catch (IOException e)
		{
			Logger.error(e.getMessage());
			return null;
		}
		return properties;
	}
}
